require File.dirname(__FILE__) + '/tasks/compiler_tasks'
require File.dirname(__FILE__) + '/tasks/test_tasks'
require File.dirname(__FILE__) + '/tasks/file_tasks'
require File.dirname(__FILE__) + '/dotnet/framework'
require File.dirname(__FILE__) + '/facades'
require 'erb'

module Rubicant
  include Rubicant::DotNet
  include Rubicant::Tasks
  
  def csc(name, dependencies, opts={})
    CscTask.new(name => dependencies) do |csc|
      csc.target = opts[:target] unless opts[:target].nil?
      csc.references = opts[:references] unless opts[:references].nil?
      csc.out = opts[:out] unless opts[:out].nil?
      csc.debug = opts[:debug] unless opts[:debug].nil?
      csc.files = opts[:files] unless opts[:files].nil?
    end
  end
  
  def expand_template(template, output_file)
    template_string = ""
    File.open(template).each do |line|
      template_string << line
    end
    
    output = File.open(output_file, "w")
    output.puts(ERB.new(template_string).result)
    output.close
  end

  def mbunit(name, dependencies, mbunit_dir, test_dir, test_files, opts={})
    MbUnitTask.new(name => dependencies) do |mbunit|
      mbunit.mbunit_dir = mbunit_dir
      mbunit.test_dir = test_dir
      mbunit.test_files = test_files
      mbunit.assembly_path = opts[:assembly_path] unless opts[:assembly_path].nil?
      mbunit.report_folder = opts[:report_folder] unless opts[:report_folder].nil?
      mbunit.report_name_format = opts[:report_name_format] unless opts[:report_name_format].nil?
      mbunit.report_type = opts[:report_type] unless opts[:report_type].nil?
      mbunit.show_reports = opts[:show_reports] unless opts[:show_reports].nil?
      mbunit.transform = opts[:transform] unless opts[:transform].nil?
      mbunit.filter_category = opts[:filter_category] unless opts[:filter_category].nil?
      mbunit.exclude_category = opts[:exclude_category] unless opts[:exclude_category].nil?
      mbunit.filter_author = opts[:filter_author] unless opts[:filter_author].nil?
      mbunit.filter_type = opts[:filter_type] unless opts[:filter_type].nil?
      mbunit.filter_namespace = opts[:filter_namespace] unless opts[:filter_namespace].nil?
      mbunit.verbose = opts[:verbose] unless opts[:verbose].nil?
      mbunit.shadow_copy = opts[:shadow_copy] unless opts[:shadow_copy].nil?

    end
  end
  
end